﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package org.aswing.plaf.basic.background {
    import flash.events.*;
    import flash.display.*;
    import org.aswing.*;
    import org.aswing.geom.*;
    import org.aswing.plaf.*;
    import org.aswing.event.*;
    import org.aswing.graphics.*;
    import org.aswing.plaf.basic.*;

    public class ScrollBarThumb implements GroundDecorator, UIResource {

        protected var bar:JScrollBar;
        protected var thumb:AWSprite;
        protected var size:IntDimension;
        protected var verticle:Boolean;
        protected var rollover:Boolean;
        protected var pressed:Boolean;

        public function ScrollBarThumb(){
            this.thumb = new AWSprite();
            this.rollover = false;
            this.pressed = false;
            this.initSelfHandlers();
        }
        public function updateDecorator(_arg1:Component, _arg2:Graphics2D, _arg3:IntRectangle):void{
            this.thumb.x = _arg3.x;
            this.thumb.y = _arg3.y;
            this.size = _arg3.getSize();
            this.bar = JScrollBar(_arg1);
            this.verticle = (this.bar.getOrientation() == JScrollBar.VERTICAL);
            this.paint();
        }
        private function paint():void{
            var _local6:IntRectangle;
            var _local7:Number;
            var _local8:int;
            var _local10:StyleResult;
            var _local1:Number = 0;
            var _local2:Number = 0;
            var _local3:Number = this.size.width;
            var _local4:Number = this.size.height;
            this.thumb.graphics.clear();
            var _local5:Graphics2D = new Graphics2D(this.thumb.graphics);
            if (this.verticle){
                _local7 = (Math.PI / 2);
                _local8 = (_local3 - 6);
            } else {
                _local7 = 0;
                _local8 = (_local4 - 6);
            };
            _local6 = new IntRectangle(_local1, _local2, _local3, _local4);
            var _local9:StyleTune = this.bar.getStyleTune().mide;
            var _local11:ASColor = this.bar.getMideground().changeAlpha(1);
            if (!this.bar.isEnabled()){
                _local11 = _local11.offsetHLS(0, -0.06, -0.03);
                _local9 = _local9.sharpen(0.4);
            } else {
                if (this.pressed){
                    _local9 = _local9.sharpen(0.8);
                } else {
                    if (this.rollover){
                        _local11 = _local11.offsetHLS(0, 0.06, 0);
                    };
                };
            };
            _local10 = new StyleResult(_local11, _local9);
            BasicGraphicsUtils.fillGradientRoundRect(_local5, _local6, _local10, _local7);
            BasicGraphicsUtils.drawGradientRoundRectLine(_local5, _local6, 1, _local10, _local7);
            _local6 = _local6.clone();
            _local6.grow(-1, -1);
            var _local12:StyleResult = new StyleResult(_local11, _local9);
            new StyleResult(_local11, _local9).bdark = _local12.cdark.offsetHLS(0, 0.06, 0);
            _local12.blight = _local12.clight.offsetHLS(0, 0.06, 0);
            BasicGraphicsUtils.drawGradientRoundRectLine(_local5, _local6, 1, _local12, _local7);
            var _local13:int;
            var _local14:int;
            var _local15:Pen = new Pen(_local12.blight, 1, true, LineScaleMode.NORMAL, CapsStyle.SQUARE);
            var _local16:Pen = new Pen(_local10.blight, 1, true, LineScaleMode.NORMAL, CapsStyle.SQUARE);
            if (this.verticle){
                _local13 = (_local1 + 3);
                _local14 = ((_local2 + (_local4 / 2)) - 3);
                _local5.drawLine(_local15, _local13, _local14, (_local13 + _local8), _local14);
                _local14 = (_local14 + 1);
                _local5.drawLine(_local16, _local13, _local14, (_local13 + _local8), _local14);
                _local14 = (_local14 + 1);
                _local5.drawLine(_local15, _local13, _local14, (_local13 + _local8), _local14);
                _local14 = (_local14 + 1);
                _local5.drawLine(_local16, _local13, _local14, (_local13 + _local8), _local14);
                _local14 = (_local14 + 1);
                _local5.drawLine(_local15, _local13, _local14, (_local13 + _local8), _local14);
                _local14 = (_local14 + 1);
                _local5.drawLine(_local16, _local13, _local14, (_local13 + _local8), _local14);
            } else {
                _local13 = ((_local1 + (_local3 / 2)) - 3);
                _local14 = (_local2 + 3);
                _local5.drawLine(_local15, _local13, _local14, _local13, (_local14 + _local8));
                _local13 = (_local13 + 1);
                _local5.drawLine(_local16, _local13, _local14, _local13, (_local14 + _local8));
                _local13 = (_local13 + 1);
                _local5.drawLine(_local15, _local13, _local14, _local13, (_local14 + _local8));
                _local13 = (_local13 + 1);
                _local5.drawLine(_local16, _local13, _local14, _local13, (_local14 + _local8));
                _local13 = (_local13 + 1);
                _local5.drawLine(_local15, _local13, _local14, _local13, (_local14 + _local8));
                _local13 = (_local13 + 1);
                _local5.drawLine(_local16, _local13, _local14, _local13, (_local14 + _local8));
            };
            this.thumb.alpha = this.bar.getMideground().getAlpha();
        }
        public function getDisplay(_arg1:Component):DisplayObject{
            return (this.thumb);
        }
        private function initSelfHandlers():void{
            this.thumb.addEventListener(MouseEvent.ROLL_OUT, this.__rollOutListener);
            this.thumb.addEventListener(MouseEvent.ROLL_OVER, this.__rollOverListener);
            this.thumb.addEventListener(MouseEvent.MOUSE_DOWN, this.__mouseDownListener);
            this.thumb.addEventListener(ReleaseEvent.RELEASE, this.__mouseUpListener);
        }
        private function __rollOverListener(_arg1:Event):void{
            this.rollover = true;
            this.paint();
        }
        private function __rollOutListener(_arg1:Event):void{
            this.rollover = false;
            if (!this.pressed){
                this.paint();
            };
        }
        private function __mouseDownListener(_arg1:Event):void{
            this.pressed = true;
            this.paint();
        }
        private function __mouseUpListener(_arg1:Event):void{
            if (this.pressed){
                this.pressed = false;
                this.paint();
            };
        }

    }
}//package org.aswing.plaf.basic.background 
